<?php

// +----------------------------------------------------------------------

// | Description: 客户

// +----------------------------------------------------------------------

// | Author: zl

// +----------------------------------------------------------------------



namespace app\crm\controller;

use app\admin\controller\ApiCommon;

use think\response\Json;

use think\facade\Db;

use think\facade\Request;


use app\crm\model\Customer as CustomerModel;

use app\crm\model\CustomerConfig as CustomerConfigModel;

use app\crm\model\SendMsgModel;


class SendMsgController extends ApiCommon
{
    protected $customerModel;

    protected $customerConfigModel;

     /**

     * 用于判断权限

     * @permission 无限制

     * @allow 登录用户可访问

     * @other 其他根据系统设置

     **/

    public function initialize()

    {

        $action = [

            'permission' => ['insert_send_data','send_msg'],

            'allow' => ['users', 'info']

        ];

        event('CheckAuth',$action);

        $request = $this->request;

        $a = strtolower($request->action());



        $this->customerModel = new CustomerModel();

        $this->customerConfigModel = new CustomerConfigModel();

        if (!in_array($a, $action['permission'])) {

            parent::initialize();

        }

    }

    /**
     * 每日凌晨执行
     * @
     */
    public function insert_send_data()
    {
        $model = new SendMsgModel();

        $model->everydaytask();

        return resultArray(['data'=>[],'error'=>'处理成功']);

        // echo "111";
    }

    /**
     * 间隔5分钟执行
     * @
     */
    public function send_msg()
    {

        $model = new SendMsgModel();

        $model->send_tuisong();

        return resultArray(['data'=>[],'error'=>'处理成功']);

    }


    

}